package model;

import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.util.ArrayList;

public class QueuePredict<E> extends AdapterQueue<E> implements Prediction<E> {
	
	private ArrayList<Integer> xCo;
	private boolean predictPressed = false;
	@Override
	public boolean predictAdd(int guess) {
		if(guess == S.size()+1){
			return true;
		}
		else{
			return false;
		}
	}

	@Override
	public boolean predictRemove(int guess) {
		if(guess==0){
			return true;
		}
		else{
			return false;
		}
	}
	
	public ArrayList<Integer> getxCo(){
		return xCo;
	}

	public void setPressed(boolean b){
		predictPressed = b;
	}
	
	@Override
	public void paint(Graphics g) {
		 xCo = new ArrayList<Integer>();
		 
	     g.setFont(new Font("",0,15));
		 g.drawString("Queue Mode", 10, 20);

		if(!S.isEmpty()){
			
			 g.setFont(new Font("",0,50));
		     FontMetrics fm = null;
		     fm = g.getFontMetrics();
		     
		     int x = 150;
		     int y = 300;
		     int h = 60;
		     int w = 60;
		     if(predictPressed == true){
		    	 //Draws opaque box for potential addition prediction
		    	 x = 80;
		    	 xCo.add(x);
		    	 g.setColor(new Color(0,0,0,100));
		    	 g.drawRect(x,y,w,h);
		    	 x= x+h+10;
		     }		
		     g.setColor(new Color(0,0,0,200));
				for(int i=0; i< S.size(); i++){
					xCo.add(x);
				    String s = (String) S.get(i);
				    g.drawRect(x, y, w, h);
				    g.drawString(s,(((w - fm.charWidth(s.charAt(0)))/2)+x), (y + 47 ));
				    x = x + w +10;
				         			         			          
			     }	
				
				  if(predictPressed==true){
					  xCo.add(x);
					 //Draws opaque box for potential addition prediction
					 g.setColor(new Color(0,0,0,100));
					 g.drawRect(x, y, w, h);			  
				  }
			predictPressed =false;	
							
		}				
	}

}
